home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / rpc / rpcSrvStat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  7.0 KB  |  247 lines

  1. /*
  2.  * rpcSrvStat.c --
  3.  *      Manipulation and printing of the statistics taken on the server
  4.  *      side of the RPC system.  The statistics are kept as simple event
  5.  *      counts.  The counts are incremented in unsynchronized sections of
  6.  *      code.  They are reset and printed out with a pair of synchronized
  7.  *      routines.  Clients of the RPC system can use these to trace long
  8.  *      term RPC exersices.  At any time an RPC client can declare itself
  9.  *      as entering the RPC system for tracing purposes.  Any number of
  10.  *      processes can enter the system for tracing.  After the last
  11.  *      process has left the tracing system the statistics are printed on
  12.  *      the console and then reset.  (There should be a routine that
  13.  *      forces a printout of the statistics... If one process messes up
  14.  *      and doesn't leave then the stats won't get printed.)
  15.  *
  16.  * Copyright (C) 1985 Regents of the University of California
  17.  * All rights reserved.
  18.  */
  19.  
  20. #ifndef lint
  21. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/rpc/rpcSrvStat.c,v 9.5 90/11/29 21:01:56 kupfer Exp $ SPRITE (Berkeley)";
  22. #endif /* not lint */
  23.  
  24.  
  25. #include <sprite.h>
  26. #include <stdio.h>
  27. #include <bstring.h>
  28. #include <sync.h>
  29. #include <rpcSrvStat.h>
  30. #include <rpc.h>
  31. #include <rpcServer.h>
  32.  
  33. /*
  34.  * Stats are taken during RPC to help make sure all parts
  35.  * of the algorithm are exersiced and to monitor the condition
  36.  * of the system.
  37.  * Two sets of statistics are kept, a total and a triptik.
  38.  */
  39. Rpc_SrvStat rpcTotalSrvStat;
  40. Rpc_SrvStat rpcSrvStat;
  41. static int numStats = sizeof(Rpc_SrvStat) / sizeof(int);
  42.  
  43. #ifdef notdef
  44. /*
  45.  * This is the monitored data whichs keeps track of how many processes
  46.  * are using the RPC system.
  47.  */
  48. static int numTracedRpcServers;
  49.  
  50. /*
  51.  * The entering and leaving monitored.
  52.  */
  53. static Sync_Lock rpcSrvTraceLock = Sync_LockInitStatic("Rpc:rpcSrvTraceLock");
  54. #define LOCKPTR (&rpcSrvTraceLock)
  55. #endif /* notdef */
  56.  
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * Rpc_StartSrvTrace --
  62.  *
  63.  *      Start tracing of server statistics  This call should be followed
  64.  *      later by a call to Rpc_EndSrvTrace and then Rpc_PrintSrvTrace.
  65.  *      These procedures are used to start, stop, and print statistics on
  66.  *      the server side of the RPC system.
  67.  *
  68.  * Results:
  69.  *    None.
  70.  *
  71.  * Side effects:
  72.  *    Increment the number of processes in the RPC system, initialize
  73.  *    the statistics structre at the entry of the first process.
  74.  *
  75.  *----------------------------------------------------------------------
  76.  */
  77. #ifdef notdef
  78. ENTRY void
  79. Rpc_StartSrvTrace()
  80. {
  81.     LOCK_MONITOR;
  82.  
  83.  
  84.     numTracedRpcServers++;
  85.     if (numTracedRpcServers == 1) {
  86.     RpcResetSrvStat();
  87.     }
  88.  
  89.     UNLOCK_MONITOR;
  90. }
  91. #endif /* notdef */
  92.  
  93. /*
  94.  *----------------------------------------------------------------------
  95.  *
  96.  * RpcResetSrvStat --
  97.  *
  98.  *    Accumulate the server side stats in the Totals struct and
  99.  *    reset the current counters.  This is not synchronized with
  100.  *    interrupt time code so errors may occur.
  101.  *
  102.  * Results:
  103.  *    None.
  104.  *
  105.  * Side effects:
  106.  *    Increment the counters in the Total struct and reset the
  107.  *    current counters to zero.
  108.  *
  109.  *----------------------------------------------------------------------
  110.  */
  111. void
  112. RpcResetSrvStat()
  113. {
  114.     register int *totalIntPtr;
  115.     register int *deltaIntPtr;
  116.     register int index;
  117.  
  118.     /*
  119.      * Add the current statistics to the totals and then
  120.      * reset the counters.  The statistic structs are cast
  121.      * into integer arrays to make this easier to maintain.
  122.      */
  123.     totalIntPtr = (int *)&rpcTotalSrvStat;
  124.     deltaIntPtr = (int *)&rpcSrvStat;
  125.     for (index = 0; index<numStats ; index++) {
  126.     *totalIntPtr += *deltaIntPtr;
  127.     totalIntPtr++;
  128.     deltaIntPtr++;
  129.     }
  130.     bzero((Address)&rpcSrvStat, sizeof(Rpc_SrvStat));
  131. }
  132.  
  133. /*
  134.  *----------------------------------------------------------------------
  135.  *
  136.  * Rpc_EndSrvTrace --
  137.  *
  138.  *    Note that a process has left the RPC system for tracing.
  139.  *    After the last process leaves the RPC system this prints out the
  140.  *    statistics that have accrued so far.
  141.  *
  142.  * Results:
  143.  *    Maybe to the printfs.
  144.  *
  145.  * Side effects:
  146.  *    Decrement the number of processes in the RPC system.
  147.  *
  148.  *----------------------------------------------------------------------
  149.  */
  150. #ifdef notdef
  151. ENTRY void
  152. Rpc_EndSrvTrace()
  153. {
  154.     LOCK_MONITOR;
  155.  
  156.     numTracedRpcServers--;
  157.     if (numTracedRpcServers <= 0) {
  158.     numTracedRpcServers = 0;
  159.  
  160.     Rpc_PrintSrvStat();
  161.     }
  162.  
  163.     UNLOCK_MONITOR;
  164. }
  165. #endif /* notdef */
  166. /*
  167.  *----------------------------------------------------------------------
  168.  *
  169.  * Rpc_PrintSrvStat --
  170.  *
  171.  *    Print the RPC server statistics.
  172.  *
  173.  * Results:
  174.  *    None.
  175.  *
  176.  * Side effects:
  177.  *    Do the prints.
  178.  *
  179.  *----------------------------------------------------------------------
  180.  */
  181. void
  182. Rpc_PrintSrvStat()
  183. {
  184.     printf("Rpc Server Statistics\n");
  185.     printf("toServer        = %5d ", rpcSrvStat.toServer);
  186.     printf("noAlloc          = %4d ", rpcSrvStat.noAlloc);
  187.     printf("invClient        = %4d ", rpcSrvStat.invClient);
  188.     printf("\n");
  189.     printf("nacks            = %4d ", rpcSrvStat.nacks);
  190.     printf("mostNackBuffers  = %4d ", rpcSrvStat.mostNackBuffers);
  191.     printf("selfNacks        = %4d ", rpcSrvStat.selfNacks);
  192.     printf("\n");
  193.     printf("serverBusy       = %4d ", rpcSrvStat.serverBusy);
  194.     printf("requests        = %5d ", rpcSrvStat.requests);
  195.     printf("impAcks         = %5d ", rpcSrvStat.impAcks);
  196.     printf("handoffs        = %5d ", rpcSrvStat.handoffs);
  197.     printf("\n");
  198.     printf("fragMsgs        = %5d ", rpcSrvStat.fragMsgs);
  199.     printf("handoffAcks      = %4d ", rpcSrvStat.handoffAcks);
  200.     printf("fragAcks         = %4d ", rpcSrvStat.fragAcks);
  201.     printf("sentPartial      = %4d ", rpcSrvStat.recvPartial);
  202.     printf("\n");
  203.     printf("busyAcks         = %4d ", rpcSrvStat.busyAcks);
  204.     printf("resends          = %4d ", rpcSrvStat.resends);
  205.     printf("badState         = %4d ", rpcSrvStat.badState);
  206.     printf("extra            = %4d ", rpcSrvStat.extra);
  207.     printf("\n");
  208.     printf("reclaims         = %4d ", rpcSrvStat.reclaims);
  209.     printf("reassembly      = %5d ", rpcSrvStat.reassembly);
  210.     printf("dupFrag          = %4d ", rpcSrvStat.dupFrag);
  211.     printf("nonFrag          = %4d ", rpcSrvStat.nonFrag);
  212.     printf("\n");
  213.     printf("fragAborts       = %4d ", rpcSrvStat.fragAborts);
  214.     printf("recvPartial      = %4d ", rpcSrvStat.recvPartial);
  215.     printf("closeAcks        = %4d ", rpcSrvStat.closeAcks);
  216.     printf("discards         = %4d ", rpcSrvStat.discards);
  217.     printf("\n");
  218.     printf("unknownAcks      = %4d ", rpcSrvStat.unknownAcks);
  219.     printf("\n");
  220. }
  221.  
  222. /*
  223.  *----------------------------------------------------------------------
  224.  *
  225.  * Rpc_PrintServiceCount --
  226.  *
  227.  *    Print the RPC service call counts.
  228.  *
  229.  * Results:
  230.  *    None.
  231.  *
  232.  * Side effects:
  233.  *    Do the prints.
  234.  *
  235.  *----------------------------------------------------------------------
  236.  */
  237. void
  238. Rpc_PrintServiceCount()
  239. {
  240.     register int call;
  241.  
  242.     printf("Rpc Service Calls\n");
  243.     for (call=0 ; call<=RPC_LAST_COMMAND ; call++) {
  244.     printf("%-15s %8d\n", rpcService[call].name, rpcServiceCount[call]);
  245.     }
  246. }
  247.